/*
 * @lc app=leetcode.cn id=1470 lang=typescript
 *
 * [1470] 重新排列数组
 */

// @lc code=start
function shuffle(nums: number[], n: number): number[] {
    let trigger = false;
    let now = 0;
    const final: number[] = [];
    while (now < nums.length / 2) {
        const index = trigger ? now + nums.length / 2 : now;
        final.push(nums[index]);
        if (trigger) {
            trigger = false;
            now++;
        } else {
            trigger = true;
        }
    }
    return final;
}
// @lc code=end
